package com.changgou.goods.dao;

import com.changgou.goods.pojo.Brand;
import com.changgou.goods.pojo.Category;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;
import java.util.Map;

/**
 * 根据分类名称查询品牌列表
 */
public interface BrandMapper extends Mapper<Brand> {
    @Select("select name,image from tb_brand where id in (select brand_id from tb_category_brand where category_id in (select id from tb_category where name = #{name})) order by seq")
    List<Map> findListByCategoryName(@Param("name") String categoryName);



    @Select("SELECT * from tb_category where id not in (SELECT parent_id from tb_category)")
    List<Map> third();

    @Select("SELECT * from tb_category where parent_id in(SELECT id from tb_category) and id in (SELECT parent_id from tb_category)")
    List<Map> second();

    @Select("SELECT * from tb_category where parent_id = '0'")
    List<Map> first();

}
